


export default class ListViewScene extends Phaser.Scene {
    constructor() {
        super('listViewScene')
    }

    // Initialization code here
    init() {
        console.log("listViewScene init ");

    }

    // Preload assets here
    preload() {
        console.log("listViewScene preload ");
    }

    // Create game objects and set up the scene here
    create() {
        this.myList = new ListView(this);
        const item1 = this.add.text(0, 10, '列表项 1', { fontSize: '16px', fill: '#fff' });
        const item2 = this.add.text(0, 40, '列表项 2', { fontSize: '16px', fill: '#fff' });
        item1.setInteractive()
        item1.on("pointerdown",(e) => {
        })
        // 将项目添加到ListView，使用自定义的addItem方法
        this.myList.addItem(item1);
        this.myList.addItem(item2);
    }

    // Update game logic each frame here
    update() {
        console.log("listViewScene update ");
    }
}




class ListView extends Phaser.GameObjects.Container {
    constructor(scene) {
        super(scene);
        this.items = [];
        scene.add.existing(this);
    }

    addItem(item) {
        this.add(item);
        this.items.push(item);
    }
}